home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / gtlayout-Source.lha / LT_HandleInput.c < prev    next >
C/C++ Source or Header  |  1995-06-11  |  42KB  |  1,869 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID LIBENT
  10. LT_HandleInput(REG(a0) LayoutHandle *Handle,REG(d0) ULONG MsgQualifier,REG(a1) ULONG *MsgClass,REG(a2) UWORD *MsgCode,REG(a3) struct Gadget **MsgGadget)
  11. {
  12.     ObjectNode    *Node;
  13.     BOOLEAN      Activate = FALSE;
  14.  
  15.     if(!Handle)
  16.         return;
  17.  
  18.     if(Handle -> Failed)
  19.     {
  20.         *MsgClass = IDCMP_CLOSEWINDOW;
  21.  
  22.         if(!Handle -> NeedDelay)
  23.             Handle -> NeedDelay = TRUE;
  24.         else
  25.             LTP_Delay(0,500000);
  26.  
  27.         return;
  28.     }
  29.  
  30.     switch(*MsgClass)
  31.     {
  32.         case IDCMP_CHANGEWINDOW:
  33.  
  34.             if(!(Handle -> Window -> Flags & WFLG_SIZEGADGET) && (Handle -> Window -> Flags & WFLG_HASZOOM) && !V39)
  35.             {
  36. #ifdef DO_BOOPSI_KIND
  37.                 if(Handle -> BOOPSIList)
  38.                     RefreshGList((struct Gadget *)Handle -> BOOPSIList,Handle -> Window,NULL,(UWORD)-1);
  39. #endif    /* DO_BOOPSI_KIND */
  40.  
  41.                 RefreshGList(Handle -> List,Handle -> Window,NULL,(UWORD)-1);
  42.  
  43.                 GT_RefreshWindow(Handle -> Window,NULL);
  44.  
  45.                 LTP_DrawGroup(Handle,Handle -> TopGroup);
  46.             }
  47.  
  48.             break;
  49.  
  50.         case IDCMP_NEWSIZE:
  51.  
  52.                 // Did the user cancel the resize operation?
  53.  
  54.             if(Handle -> SizeVerified && Handle -> SizeWidth == Handle -> Window -> Width && Handle -> SizeHeight == Handle -> Window -> Height)
  55.             {
  56.                 Handle -> SizeVerified    = FALSE;
  57.                 Handle -> SizeWidth    = 0;
  58.                 Handle -> SizeHeight    = 0;
  59.  
  60.                     // Put the gadgets back in
  61.  
  62.                 AddGList(Handle -> Window,Handle -> List,(UWORD)-1,(UWORD)-1,NULL);
  63.             }
  64.             else
  65.             {
  66.                 struct IBox Box;
  67.  
  68.                 Handle -> SizeWidth    = 0;
  69.                 Handle -> SizeHeight    = 0;
  70.  
  71.                 Box . Left    = 0;
  72.                 Box . Top    = 0;
  73.                 Box . Width    = Handle -> Window -> Width;
  74.                 Box . Height    = Handle -> Window -> Height;
  75.  
  76.                 LT_LockWindow(Handle -> Window);
  77.  
  78.                 if(Handle -> ResizeView)
  79.                     Handle -> ResizeView -> Special . List . IgnoreListContents = TRUE;
  80.  
  81.                 LT_RebuildTags(Handle,TRUE,
  82.                     LAWN_Bounds,    &Box,
  83.                 TAG_DONE);
  84.  
  85.                 LT_UnlockWindow(Handle -> Window);
  86.  
  87.                 if(Handle -> Failed)
  88.                     *MsgClass = IDCMP_CLOSEWINDOW;
  89.                 else
  90.                     *MsgClass = NULL;
  91.             }
  92.  
  93.             break;
  94.  
  95.         case IDCMP_REFRESHWINDOW:
  96.  
  97.             if(Handle -> AutoRefresh)
  98.             {
  99.                 LT_BeginRefresh(Handle);
  100.  
  101.                 LT_EndRefresh(Handle,TRUE);
  102.  
  103.                 *MsgClass = NULL;
  104.             }
  105.  
  106.             break;
  107.  
  108.         case IDCMP_INTUITICKS:
  109.  
  110.             if(Handle -> ActiveIncrementer)
  111.             {
  112.                 Handle -> IncrementerCountdown--;
  113.  
  114.                 if(Handle -> IncrementerCountdown <= 0)
  115.                 {
  116.                     if(Handle -> ActiveIncrementer -> Host -> Flags & GFLG_SELECTED)
  117.                     {
  118.                         if(Handle -> ActiveIncrementer -> Type == TAPEDECK_KIND)
  119.                         {
  120.                             *MsgClass    = IDCMP_GADGETUP;
  121.                             *MsgCode    = 0;
  122.                             *MsgGadget    = Handle -> ActiveIncrementer -> Host;
  123.                         }
  124.                         else
  125.                         {
  126.                             struct ObjectNode    *Parent;
  127.                             LONG             Number;
  128.  
  129.                             *MsgClass    = IDCMP_GADGETUP;
  130.                             *MsgCode    = 0;
  131.                             *MsgGadget    = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
  132.  
  133.                             Parent = (*MsgGadget) -> UserData;
  134.  
  135.                             if(Parent -> Special . Integer . IncrementerHook)
  136.                                 Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),Handle -> ActiveIncrementer -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  137.                             else
  138.                                 Number = ((LONG)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE)) + Handle -> ActiveIncrementer -> Special . Incrementer . Amount;
  139.  
  140.                             if(Number >= Parent -> Min && Number <= Parent -> Max)
  141.                                 LT_SetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
  142.                         }
  143.                     }
  144.  
  145.                     Handle -> IncrementerCountdown = 2;
  146.                 }
  147.             }
  148.  
  149.             break;
  150.  
  151.         case IDCMP_RAWKEY:
  152.         {
  153.             UBYTE            Buffer[10],Key;
  154.             struct InputEvent    event;
  155.             BOOLEAN         KeyUp;
  156.  
  157.             if((*MsgCode & ~IECODE_UP_PREFIX) == 95 && Handle -> HelpHook)
  158.             {
  159.                 if(!(*MsgCode & IECODE_UP_PREFIX))
  160.                 {
  161.                     ObjectNode    *Item;
  162.                     struct HelpMsg     Message;
  163.                     struct IBox     Box;
  164.  
  165.                     Item = LTP_FindNode_Position(Handle -> TopGroup,Handle -> Window -> MouseX,Handle -> Window -> MouseY);
  166.  
  167.                     if(Item == Handle -> TopGroup)
  168.                     {
  169.                         if(Item -> ID <= PHANTOM_GROUP_ID)
  170.                             Item = NULL;
  171.                     }
  172.  
  173.                     if(Item)
  174.                     {
  175.                         Message . ObjectID = Item -> ID;
  176.  
  177.                         Box . Left    = Item -> Left;
  178.                         Box . Top    = Item -> Top;
  179.                         Box . Width    = Item -> Width;
  180.                         Box . Height    = Item -> Height;
  181.                     }
  182.                     else
  183.                     {
  184.                         Message . ObjectID = -1;
  185.  
  186.                         Box . Left    = 0;
  187.                         Box . Top    = 0;
  188.                         Box . Width    = Handle -> Window -> Width;
  189.                         Box . Height    = Handle -> Window -> Height;
  190.                     }
  191.  
  192.                     Message . Handle = Handle;
  193.  
  194.                     CallHookPkt(Handle -> HelpHook,&Message,&Box);
  195.                 }
  196.  
  197.                 if(Handle -> RawKeyFilter)
  198.                     *MsgClass = NULL;
  199.  
  200.                 break;
  201.             }
  202.  
  203.             if((*MsgCode >= 99 && *MsgCode <= 103) || *MsgCode == 96 || *MsgCode == 97)
  204.             {
  205.                 if(Handle -> RawKeyFilter)
  206.                     *MsgClass = NULL;
  207.  
  208.                 break;
  209.             }
  210.  
  211.             event . ie_NextEvent        = NULL;
  212.             event . ie_Code         = (*MsgCode) & ~IECODE_UP_PREFIX;
  213.             event . ie_Qualifier        = MsgQualifier & ~QUALIFIER_SHIFT;
  214.             event . ie_Class        = IECLASS_RAWKEY;
  215.             event . ie_SubClass        = 0;
  216.             event . ie_position . ie_addr    = (APTR)*MsgGadget;
  217.  
  218.             Buffer[0] = 0;
  219.  
  220.             if(MapRawKey(&event,Buffer,9,NULL) < 1)
  221.             {
  222.                 if(Handle -> RawKeyFilter)
  223.                     *MsgClass = NULL;
  224.  
  225.                 break;
  226.             }
  227.  
  228.             if(!(Key = Buffer[0]))
  229.             {
  230.                 if(Handle -> RawKeyFilter)
  231.                     *MsgClass = NULL;
  232.  
  233.                 break;
  234.             }
  235.  
  236.             if((*MsgCode) & IECODE_UP_PREFIX)
  237.                 KeyUp = TRUE;
  238.             else
  239.                 KeyUp = FALSE;
  240.  
  241.             if(!KeyUp && Handle -> CursorKey && (*MsgCode == CURSORUP || *MsgCode == CURSORDOWN))
  242.             {
  243.                 ObjectNode    *Node;
  244.                 struct Gadget    *Gadget;
  245.                 LONG         NewState;
  246.  
  247.                 Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  248.  
  249.                 Node        = Handle -> CursorKey;
  250.                 Gadget        = Node -> Host;
  251.                 NewState    = Node -> Current;
  252.  
  253.                 if(*MsgCode == CURSORDOWN)
  254.                 {
  255.                     if(MsgQualifier & QUALIFIER_SHIFT)
  256.                         NewState += Node -> Lines;
  257.                     else
  258.                     {
  259.                         if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
  260.                             NewState = Node -> Max;
  261.                         else
  262.                             NewState++;
  263.                     }
  264.                 }
  265.                 else
  266.                 {
  267.                     if(MsgQualifier & QUALIFIER_SHIFT)
  268.                         NewState -= Node -> Lines;
  269.                     else
  270.                     {
  271.                         if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
  272.                             NewState = Node -> Min;
  273.                         else
  274.                             NewState--;
  275.                     }
  276.                 }
  277.  
  278.                 if(NewState < Node -> Min)
  279.                     NewState = Node -> Min;
  280.                 else
  281.                 {
  282.                     if(NewState > Node -> Max)
  283.                         NewState = Node -> Max;
  284.                 }
  285.  
  286.                 if(NewState != Node -> Current && Node -> Max != Node -> Min)
  287.                 {
  288.                     Node -> Current = NewState;
  289.  
  290.                     GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  291.                         GTLV_Top,        Node -> Current,
  292.                         GTLV_MakeVisible,    Node -> Current,
  293.  
  294.                         Node -> Special . List . LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node -> Current,
  295.                     TAG_DONE);
  296.  
  297.                     LTP_PutStorage(Node);
  298.  
  299.                     *MsgClass    = IDCMP_GADGETUP;
  300.                     *MsgCode    = Node -> Current;
  301.                     *MsgGadget    = Gadget;
  302.                 }
  303.                 else
  304.                 {
  305.                     if(Handle -> RawKeyFilter)
  306.                         *MsgClass = NULL;
  307.                 }
  308.  
  309.                 return;
  310.             }
  311.  
  312.             if(Key == '\t' && !KeyUp)
  313.             {
  314.                 ObjectNode *Node;
  315.  
  316.                 if(Handle -> RawKeyFilter)
  317.                     *MsgClass = NULL;
  318.  
  319.                 if(Node = Handle -> TabKey)
  320.                 {
  321.                     if(!(Node -> Disabled))
  322.                     {
  323.                         LONG Choice;
  324.  
  325.                         if(MsgQualifier & QUALIFIER_SHIFT)
  326.                             Choice = Node -> Current - 1;
  327.                         else
  328.                             Choice = Node -> Current + 1;
  329.  
  330.                         if(Choice < Node -> Min)
  331.                             Choice = Node -> Max;
  332.                         else
  333.                         {
  334.                             if(Choice > Node -> Max)
  335.                                 Choice = Node -> Min;
  336.                         }
  337.  
  338.                         if(Choice != Node -> Current)
  339.                         {
  340.                             LONG AutoPageID,Type;
  341.  
  342.                             if(Node -> Type == CYCLE_KIND)
  343.                             {
  344.                                 AutoPageID    = Node -> Special . Cycle . AutoPageID;
  345.                                 Type        = GTCY_Active;
  346.                                 *MsgClass    = IDCMP_GADGETUP;
  347.  
  348.                                 LTP_BlinkButton(Handle,Node -> Host);
  349.                             }
  350.                             else
  351.                             {
  352.                                 AutoPageID    = Node -> Special . Radio . AutoPageID;
  353.                                 Type        = GTMX_Active;
  354.                                 *MsgClass    = IDCMP_GADGETDOWN;
  355.                             }
  356.  
  357.                             *MsgCode    = (UWORD)Choice;
  358.                             *MsgGadget    = Node -> Host;
  359.  
  360.                             LT_SetAttributes(Handle,Node -> ID,
  361.                                 Type,Choice,
  362.                             TAG_DONE);
  363.  
  364.                             if(AutoPageID != -1)
  365.                             {
  366.                                 LT_SetAttributes(Handle,AutoPageID,
  367.                                     LAGR_ActivePage,Choice,
  368.                                 TAG_DONE);
  369.  
  370.                                 if(Handle -> Failed)
  371.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  372.                             }
  373.                         }
  374.                     }
  375.                 }
  376.  
  377.                 return;
  378.             }
  379.  
  380.             if(Key == '\33' && !KeyUp)
  381.             {
  382.                 ObjectNode *Node;
  383.  
  384.                 Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  385.  
  386.                 if(Node = Handle -> EscKey)
  387.                 {
  388.                     if(!Node -> Disabled)
  389.                     {
  390.                         LTP_BlinkButton(Handle,Node -> Host);
  391.  
  392.                         *MsgCode    = 0;
  393.                         *MsgGadget    = Node -> Host;
  394.                         *MsgClass    = IDCMP_GADGETUP;
  395.                     }
  396.                     else
  397.                     {
  398.                         if(Handle -> RawKeyFilter)
  399.                             *MsgClass = NULL;
  400.                     }
  401.  
  402.                     return;
  403.                 }
  404.  
  405.                 if(Handle -> Window -> Flags & WFLG_CLOSEGADGET)
  406.                 {
  407.                     *MsgCode    = 0;
  408.                     *MsgGadget    = NULL;
  409.                     *MsgClass    = IDCMP_CLOSEWINDOW;
  410.                 }
  411.                 else
  412.                 {
  413.                     if(Handle -> RawKeyFilter)
  414.                         *MsgClass = NULL;
  415.                 }
  416.  
  417.                 return;
  418.             }
  419.             else
  420.             {
  421.                 struct Gadget    *Gadget;
  422.                 ObjectNode    *Node;
  423.                 LONG         i;
  424.                 BOOLEAN      FoundIt = FALSE,
  425.                          Forward;
  426.  
  427.                 if(MsgQualifier & QUALIFIER_SHIFT)
  428.                     Forward = FALSE;
  429.                 else
  430.                     Forward = TRUE;
  431.  
  432.                 if(Handle -> ReturnKey && Key == '\r')
  433.                 {
  434.                     Node = Handle -> ReturnKey;
  435.  
  436.                     if(!KeyUp && !Node -> Disabled)
  437.                     {
  438.                         LTP_BlinkButton(Handle,Node -> Host);
  439.  
  440.                         *MsgClass    = IDCMP_GADGETUP;
  441.                         *MsgCode    = 0;
  442.                         *MsgGadget    = Node -> Host;
  443.                     }
  444.                     else
  445.                     {
  446.                         if(Handle -> RawKeyFilter)
  447.                             *MsgClass = NULL;
  448.                     }
  449.  
  450.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  451.  
  452.                     return;
  453.                 }
  454.  
  455.                 for(i = 0 ; !FoundIt && i < Handle -> Count ; i++)
  456.                 {
  457.                     if(Gadget = Handle -> GadgetArray[i])
  458.                     {
  459.                         if(GETOBJECT(Gadget,Node))
  460.                         {
  461.                             if(Key == Node -> Key)
  462.                             {
  463.                                 if(Node -> Disabled)
  464.                                     break;
  465.                                 else
  466.                                 {
  467.                                     switch(Node -> Type)
  468.                                     {
  469. #ifdef DO_BOOPSI_KIND
  470.                                         case BOOPSI_KIND:
  471.  
  472.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  473.                                             {
  474.                                                 if(Node -> Special . BOOPSI . ActivateHook)
  475.                                                 {
  476.                                                     if(CallHookPkt(Node -> Special . BOOPSI . ActivateHook,(APTR)Handle,(APTR)Node -> Host))
  477.                                                     {
  478.                                                         if(Handle -> RawKeyFilter)
  479.                                                             *MsgClass = NULL;
  480.  
  481.                                                         break;
  482.                                                     }
  483.                                                 }
  484.  
  485.                                                 *MsgClass    = IDCMP_GADGETUP;
  486.                                                 *MsgCode    = (MsgQualifier & QUALIFIER_SHIFT) ? -1 : 1;
  487.                                                 *MsgGadget    = Gadget;
  488.                                             }
  489.                                             else
  490.                                             {
  491.                                                 if(Handle -> RawKeyFilter)
  492.                                                     *MsgClass = NULL;
  493.                                             }
  494.  
  495.                                             break;
  496. #endif    /* DO_BOOPSI_KIND */
  497. #ifdef DO_TAPEDECK_KIND
  498.                                         case TAPEDECK_KIND:
  499.  
  500.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  501.                                             {
  502.                                                 if(Node -> Special . TapeDeck . Toggle)
  503.                                                 {
  504.                                                     LT_SetAttributes(Handle,Node -> ID,
  505.                                                         LAPR_Object,    Node,
  506.                                                         LATD_Pressed,    !Node -> Current,
  507.                                                     TAG_DONE);
  508.  
  509.                                                     LTP_PutStorage(Node);
  510.                                                 }
  511.                                                 else
  512.                                                     LTP_BlinkButton(Handle,Gadget);
  513.  
  514.                                                 if(Gadget -> Flags & GFLG_SELECTED)
  515.                                                     *MsgCode = TRUE;
  516.                                                 else
  517.                                                     *MsgCode = FALSE;
  518.  
  519.                                                 *MsgClass    = IDCMP_GADGETUP;
  520.                                                 *MsgGadget    = Gadget;
  521.                                             }
  522.                                             else
  523.                                             {
  524.                                                 if(Handle -> RawKeyFilter)
  525.                                                     *MsgClass = NULL;
  526.                                             }
  527.  
  528.                                             break;
  529. #endif    /* DO_TAPEDECK_KIND */
  530.                                         case CHECKBOX_KIND:
  531.  
  532.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  533.                                             {
  534.                                                 Node -> Current = !Node -> Current;
  535.  
  536.                                                 LTP_PutStorage(Node);
  537.  
  538.                                                 GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  539.                                                     GTCB_Checked,Node -> Current,
  540.                                                 TAG_DONE);
  541.  
  542.                                                 *MsgClass    = IDCMP_GADGETUP;
  543.                                                 *MsgCode    = Node -> Current;
  544.                                                 *MsgGadget    = Gadget;
  545.                                             }
  546.                                             else
  547.                                             {
  548.                                                 if(Handle -> RawKeyFilter)
  549.                                                     *MsgClass = NULL;
  550.                                             }
  551.  
  552.                                             FoundIt = TRUE;
  553.  
  554.                                             break;
  555.  
  556.                                         case LISTVIEW_KIND:
  557.  
  558.                                             if(!KeyUp)
  559.                                             {
  560.                                                 BOOLEAN setAttrs = FALSE;
  561.  
  562.                                                 if(Forward)
  563.                                                 {
  564.                                                     if(Node -> Current < Node -> Max)
  565.                                                     {
  566.                                                         Node -> Current++;
  567.  
  568.                                                         setAttrs = TRUE;
  569.                                                     }
  570.                                                 }
  571.                                                 else
  572.                                                 {
  573.                                                     if(Node -> Current > Node -> Min)
  574.                                                     {
  575.                                                         Node -> Current--;
  576.  
  577.                                                         setAttrs = TRUE;
  578.                                                     }
  579.                                                 }
  580.  
  581.                                                 if(setAttrs)
  582.                                                 {
  583.                                                     if(Node -> Current < 0)
  584.                                                     {
  585.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  586.                                                             GTLV_Selected,Node -> Current,
  587.                                                         TAG_DONE);
  588.                                                     }
  589.                                                     else
  590.                                                     {
  591.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  592.                                                             GTLV_Top,        Node -> Current,
  593.                                                             GTLV_MakeVisible,    Node -> Current,
  594.                                                             Node -> Special . List . LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node -> Current,
  595.                                                         TAG_DONE);
  596.                                                     }
  597.  
  598.                                                     LTP_PutStorage(Node);
  599.  
  600.                                                     *MsgClass    = IDCMP_GADGETUP;
  601.                                                     *MsgCode    = Node -> Current;
  602.                                                     *MsgGadget    = Gadget;
  603.                                                 }
  604.                                                 else
  605.                                                 {
  606.                                                     if(Handle -> RawKeyFilter)
  607.                                                         *MsgClass = NULL;
  608.                                                 }
  609.                                             }
  610.                                             else
  611.                                             {
  612.                                                 if(Handle -> RawKeyFilter)
  613.                                                     *MsgClass = NULL;
  614.                                             }
  615.  
  616.                                             FoundIt = TRUE;
  617.  
  618.                                             break;
  619.  
  620.                                         case MX_KIND:
  621.  
  622.                                             if(!KeyUp)
  623.                                             {
  624.                                                 if(Forward)
  625.                                                 {
  626.                                                     if(Node -> Current < Node -> Max)
  627.                                                     {
  628.                                                         Node -> Current++;
  629.  
  630.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  631.                                                             GTMX_Active,Node -> Current,
  632.                                                         TAG_DONE);
  633.  
  634.                                                         LTP_PutStorage(Node);
  635.  
  636.                                                         *MsgClass    = IDCMP_GADGETDOWN;
  637.                                                         *MsgCode    = Node -> Current;
  638.                                                         *MsgGadget    = Gadget;
  639.                                                     }
  640.                                                     else
  641.                                                     {
  642.                                                         if(Handle -> RawKeyFilter)
  643.                                                             *MsgClass = NULL;
  644.                                                     }
  645.                                                 }
  646.                                                 else
  647.                                                 {
  648.                                                     if(Node -> Current > Node -> Min)
  649.                                                     {
  650.                                                         Node -> Current--;
  651.  
  652.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  653.                                                             GTMX_Active,Node -> Current,
  654.                                                         TAG_DONE);
  655.  
  656.                                                         LTP_PutStorage(Node);
  657.  
  658.                                                         *MsgClass    = IDCMP_GADGETDOWN;
  659.                                                         *MsgCode    = Node -> Current;
  660.                                                         *MsgGadget    = Gadget;
  661.                                                     }
  662.                                                     else
  663.                                                         *MsgClass = NULL;
  664.                                                 }
  665.                                             }
  666.                                             else
  667.                                                 *MsgClass = NULL;
  668.  
  669.                                             if(*MsgClass)
  670.                                             {
  671.                                                 if(Node -> Special . Radio . AutoPageID != -1)
  672.                                                 {
  673.                                                     LT_SetAttributes(Handle,Node -> Special . Radio . AutoPageID,
  674.                                                         LAGR_ActivePage,Node -> Current,
  675.                                                     TAG_DONE);
  676.  
  677.                                                     if(Handle -> Failed)
  678.                                                         *MsgClass = IDCMP_CLOSEWINDOW;
  679.                                                     else
  680.                                                     {
  681.                                                         if(Handle -> RawKeyFilter)
  682.                                                             *MsgClass = NULL;
  683.                                                     }
  684.                                                 }
  685.                                             }
  686.  
  687.                                             FoundIt = TRUE;
  688.  
  689.                                             break;
  690.  
  691.                                         case TEXT_KIND:
  692.  
  693.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  694.                                             {
  695.                                                 if(Node -> Special . Text . Picker)
  696.                                                 {
  697.                                                     LTP_BlinkButton(Handle,Node -> Special . Text . Picker);
  698.  
  699.                                                     *MsgClass    = IDCMP_IDCMPUPDATE;
  700.                                                     *MsgCode    = 0;
  701.                                                     *MsgGadget    = Gadget;
  702.                                                 }
  703.                                                 else
  704.                                                 {
  705.                                                     if(Handle -> RawKeyFilter)
  706.                                                         *MsgClass = NULL;
  707.                                                 }
  708.                                             }
  709.                                             else
  710.                                             {
  711.                                                 if(Handle -> RawKeyFilter)
  712.                                                     *MsgClass = NULL;
  713.                                             }
  714.  
  715.                                             FoundIt = TRUE;
  716.  
  717.                                             break;
  718.  
  719.                                         case NUMBER_KIND:
  720.  
  721.                                             if(Handle -> RawKeyFilter)
  722.                                                 *MsgClass = NULL;
  723.  
  724.                                             FoundIt = TRUE;
  725.  
  726.                                             break;
  727.  
  728.                                         case CYCLE_KIND:
  729.  
  730.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  731.                                             {
  732.                                                 LTP_BlinkButton(Handle,Gadget);
  733.  
  734.                                                 if(Forward)
  735.                                                 {
  736.                                                     if(Node -> Current < Node -> Max)
  737.                                                         Node -> Current++;
  738.                                                     else
  739.                                                         Node -> Current = Node -> Min;
  740.                                                 }
  741.                                                 else
  742.                                                 {
  743.                                                     if(Node -> Current > Node -> Min)
  744.                                                         Node -> Current--;
  745.                                                     else
  746.                                                         Node -> Current = Node -> Max;
  747.                                                 }
  748.  
  749.                                                 LTP_PutStorage(Node);
  750.  
  751.                                                 GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  752.                                                     GTCY_Active,Node -> Current,
  753.                                                 TAG_DONE);
  754.  
  755.                                                 *MsgClass    = IDCMP_GADGETUP;
  756.                                                 *MsgCode    = Node -> Current;
  757.                                                 *MsgGadget    = Gadget;
  758.  
  759.                                                 if(Node -> Special . Cycle . AutoPageID != -1)
  760.                                                 {
  761.                                                     LT_SetAttributes(Handle,Node -> Special . Cycle . AutoPageID,
  762.                                                         LAGR_ActivePage,Node -> Current,
  763.                                                     TAG_DONE);
  764.  
  765.                                                     if(Handle -> Failed)
  766.                                                         *MsgClass = IDCMP_CLOSEWINDOW;
  767.                                                     else
  768.                                                     {
  769.                                                         if(Handle -> RawKeyFilter)
  770.                                                             *MsgClass = NULL;
  771.                                                     }
  772.                                                 }
  773.                                             }
  774.                                             else
  775.                                             {
  776.                                                 if(Handle -> RawKeyFilter)
  777.                                                     *MsgClass = NULL;
  778.                                             }
  779.  
  780.                                             FoundIt = TRUE;
  781.  
  782.                                             break;
  783.  
  784.                                         case PALETTE_KIND:
  785.  
  786.                                             if(!KeyUp)
  787.                                             {
  788.                                                 if(Node -> Special . Palette . UsePicker)
  789.                                                 {
  790.                                                     if(!(MsgQualifier & IEQUALIFIER_REPEAT))
  791.                                                     {
  792.                                                         LTP_BlinkButton(Handle,Node -> Special . Palette . Picker);
  793.  
  794.                                                         *MsgClass    = IDCMP_IDCMPUPDATE;
  795.                                                         *MsgCode    = 0;
  796.                                                         *MsgGadget    = Gadget;
  797.                                                     }
  798.                                                     else
  799.                                                     {
  800.                                                         if(Handle -> RawKeyFilter)
  801.                                                             *MsgClass = NULL;
  802.                                                     }
  803.  
  804.                                                     FoundIt = TRUE;
  805.  
  806.                                                     break;
  807.                                                 }
  808.  
  809.                                                 if(Node -> Special . Palette . TranslateBack)
  810.                                                 {
  811.                                                     LONG Index = Node -> Special . Palette . TranslateBack[Node -> Current];
  812.  
  813.                                                     if(Index < Node -> Min)
  814.                                                         Index = Node -> Min;
  815.                                                     else
  816.                                                     {
  817.                                                         if(Index > Node -> Max)
  818.                                                             Index = Node -> Max;
  819.                                                     }
  820.  
  821.                                                     if(Forward)
  822.                                                     {
  823.                                                         if(Index < Node -> Max)
  824.                                                             Index++;
  825.                                                         else
  826.                                                             Index = Node -> Min;
  827.                                                     }
  828.                                                     else
  829.                                                     {
  830.                                                         if(Index > Node -> Min)
  831.                                                             Index--;
  832.                                                         else
  833.                                                             Index = Node -> Max;
  834.                                                     }
  835.  
  836.                                                     if(Index < Node -> Min)
  837.                                                         Index = Node -> Min;
  838.                                                     else
  839.                                                     {
  840.                                                         if(Index > Node -> Max)
  841.                                                             Index = Node -> Max;
  842.                                                     }
  843.  
  844.                                                     Node -> Current = Node -> Special . Palette . ColourTable[Index];
  845.                                                 }
  846.                                                 else
  847.                                                 {
  848.                                                     if(Forward)
  849.                                                     {
  850.                                                         if(Node -> Current < Node -> Max)
  851.                                                             Node -> Current++;
  852.                                                         else
  853.                                                             Node -> Current = Node -> Min;
  854.                                                     }
  855.                                                     else
  856.                                                     {
  857.                                                         if(Node -> Current > Node -> Min)
  858.                                                             Node -> Current--;
  859.                                                         else
  860.                                                             Node -> Current = Node -> Max;
  861.                                                     }
  862.                                                 }
  863.  
  864.                                                 LTP_PutStorage(Node);
  865.  
  866.                                                 GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  867.                                                     GTPA_Color,Node -> Current,
  868.                                                 TAG_DONE);
  869.  
  870.                                                 *MsgClass    = IDCMP_GADGETUP;
  871.                                                 *MsgCode    = Node -> Current;
  872.                                                 *MsgGadget    = Gadget;
  873.                                             }
  874.                                             else
  875.                                             {
  876.                                                 if(Handle -> RawKeyFilter)
  877.                                                     *MsgClass = NULL;
  878.                                             }
  879.  
  880.                                             FoundIt = TRUE;
  881.  
  882.                                             break;
  883.  
  884.                                         case SLIDER_KIND:
  885.  
  886.                                             if(KeyUp)
  887.                                             {
  888.                                                 *MsgClass    = IDCMP_GADGETUP;
  889.                                                 *MsgCode    = Node -> Current;
  890.                                                 *MsgGadget    = Gadget;
  891.                                             }
  892.                                             else
  893.                                             {
  894.                                                 if(Forward)
  895.                                                 {
  896.                                                     if(Node -> Current < Node -> Max)
  897.                                                     {
  898.                                                         Node -> Current++;
  899.  
  900.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  901.                                                             GTSL_Level,Node -> Current,
  902.                                                         TAG_DONE);
  903.  
  904.                                                         LTP_PutStorage(Node);
  905.  
  906.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  907.                                                         *MsgCode    = Node -> Current;
  908.                                                         *MsgGadget    = Gadget;
  909.                                                     }
  910.                                                     else
  911.                                                     {
  912.                                                         if(Handle -> RawKeyFilter)
  913.                                                             *MsgClass = NULL;
  914.                                                     }
  915.                                                 }
  916.                                                 else
  917.                                                 {
  918.                                                     if(Node -> Current > Node -> Min)
  919.                                                     {
  920.                                                         Node -> Current--;
  921.  
  922.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  923.                                                             GTSL_Level,Node -> Current,
  924.                                                         TAG_DONE);
  925.  
  926.                                                         LTP_PutStorage(Node);
  927.  
  928.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  929.                                                         *MsgCode    = Node -> Current;
  930.                                                         *MsgGadget    = Gadget;
  931.                                                     }
  932.                                                     else
  933.                                                     {
  934.                                                         if(Handle -> RawKeyFilter)
  935.                                                             *MsgClass = NULL;
  936.                                                     }
  937.                                                 }
  938.                                             }
  939.  
  940.                                             FoundIt = TRUE;
  941.  
  942.                                             break;
  943.  
  944. #ifdef DO_LEVEL_KIND
  945.                                         case LEVEL_KIND:
  946.  
  947.                                             if(KeyUp)
  948.                                             {
  949.                                                 *MsgClass    = IDCMP_GADGETUP;
  950.                                                 *MsgCode    = Node -> Special . Level . Level;
  951.                                                 *MsgGadget    = Gadget;
  952.  
  953.                                                 LTP_PutStorage(Node);
  954.                                             }
  955.                                             else
  956.                                             {
  957.                                                 if(Forward)
  958.                                                 {
  959.                                                     if(Node -> Special . Level . Level < Node -> Special . Level . Max)
  960.                                                     {
  961.                                                         Node -> Special . Level . Level++;
  962.  
  963.                                                         LT_SetAttributes(Handle,Node -> ID,
  964.                                                             LAPR_Object,    Node,
  965.                                                             LAVL_Level,    Node -> Special . Level . Level,
  966.                                                         TAG_DONE);
  967.  
  968.                                                         LTP_PutStorage(Node);
  969.  
  970.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  971.                                                         *MsgCode    = Node -> Special . Level . Level;
  972.                                                         *MsgGadget    = Gadget;
  973.                                                     }
  974.                                                     else
  975.                                                     {
  976.                                                         if(Handle -> RawKeyFilter)
  977.                                                             *MsgClass = NULL;
  978.                                                     }
  979.                                                 }
  980.                                                 else
  981.                                                 {
  982.                                                     if(Node -> Special . Level . Level > Node -> Special . Level . Min)
  983.                                                     {
  984.                                                         Node -> Special . Level . Level--;
  985.  
  986.                                                         LT_SetAttributes(Handle,Node -> ID,
  987.                                                             LAPR_Object,    Node,
  988.                                                             LAVL_Level,    Node -> Special . Level . Level,
  989.                                                         TAG_DONE);
  990.  
  991.                                                         LTP_PutStorage(Node);
  992.  
  993.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  994.                                                         *MsgCode    = Node -> Special . Level . Level;
  995.                                                         *MsgGadget    = Gadget;
  996.                                                     }
  997.                                                     else
  998.                                                     {
  999.                                                         if(Handle -> RawKeyFilter)
  1000.                                                             *MsgClass = NULL;
  1001.                                                     }
  1002.                                                 }
  1003.                                             }
  1004.  
  1005.                                             FoundIt = TRUE;
  1006.  
  1007.                                             break;
  1008. #endif    /* DO_LEVEL_KIND */
  1009.                                         case SCROLLER_KIND:
  1010.  
  1011.                                             if(KeyUp)
  1012.                                             {
  1013.                                                 *MsgClass    = IDCMP_GADGETUP;
  1014.                                                 *MsgCode    = Node -> Current;
  1015.                                                 *MsgGadget    = Gadget;
  1016.                                             }
  1017.                                             else
  1018.                                             {
  1019.                                                 if(Forward)
  1020.                                                 {
  1021.                                                     if(Node -> Current < Node -> Max)
  1022.                                                     {
  1023.                                                         Node -> Current++;
  1024.  
  1025.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  1026.                                                             GTSC_Top,Node -> Current,
  1027.                                                         TAG_DONE);
  1028.  
  1029.                                                         LTP_PutStorage(Node);
  1030.  
  1031.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1032.                                                         *MsgCode    = Node -> Current;
  1033.                                                         *MsgGadget    = Gadget;
  1034.                                                     }
  1035.                                                     else
  1036.                                                     {
  1037.                                                         if(Handle -> RawKeyFilter)
  1038.                                                             *MsgClass = NULL;
  1039.                                                     }
  1040.                                                 }
  1041.                                                 else
  1042.                                                 {
  1043.                                                     if(Node -> Current > Node -> Min)
  1044.                                                     {
  1045.                                                         Node -> Current--;
  1046.  
  1047.                                                         GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
  1048.                                                             GTSC_Top,Node -> Current,
  1049.                                                         TAG_DONE);
  1050.  
  1051.                                                         LTP_PutStorage(Node);
  1052.  
  1053.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1054.                                                         *MsgCode    = Node -> Current;
  1055.                                                         *MsgGadget    = Gadget;
  1056.                                                     }
  1057.                                                     else
  1058.                                                     {
  1059.                                                         if(Handle -> RawKeyFilter)
  1060.                                                             *MsgClass = NULL;
  1061.                                                     }
  1062.                                                 }
  1063.                                             }
  1064.  
  1065.                                             FoundIt = TRUE;
  1066.  
  1067.                                             break;
  1068.  
  1069.                                         case STRING_KIND:
  1070.                                         case FRACTION_KIND:
  1071.                                         case PASSWORD_KIND:
  1072.  
  1073.                                             if(!KeyUp)
  1074.                                             {
  1075.                                                 if(Node -> Special . String . Picker && !Forward)
  1076.                                                 {
  1077.                                                     LTP_BlinkButton(Handle,Node -> Special . String . Picker);
  1078.  
  1079.                                                     *MsgClass    = IDCMP_IDCMPUPDATE;
  1080.                                                     *MsgCode    = 0;
  1081.                                                     *MsgGadget    = Gadget;
  1082.                                                 }
  1083.                                                 else
  1084.                                                 {
  1085.                                                     ActivateGadget(Gadget,Handle -> Window,NULL);
  1086.  
  1087.                                                     *MsgClass    = IDCMP_GADGETDOWN;
  1088.                                                     *MsgCode    = 0;
  1089.                                                     *MsgGadget    = Gadget;
  1090.  
  1091.                                                     Handle -> Previous = Gadget;
  1092.                                                 }
  1093.                                             }
  1094.                                             else
  1095.                                             {
  1096.                                                 if(Handle -> RawKeyFilter)
  1097.                                                     *MsgClass = NULL;
  1098.                                             }
  1099.  
  1100.                                             FoundIt = TRUE;
  1101.  
  1102.                                             break;
  1103.  
  1104.                                         case INTEGER_KIND :
  1105.  
  1106.                                             if(!KeyUp)
  1107.                                             {
  1108.                                                 if(Node -> Special . Integer . UseIncrementers)
  1109.                                                 {
  1110.                                                     ObjectNode    *incNode,*Parent = (ObjectNode *)Gadget -> UserData;
  1111.                                                     LONG         Number;
  1112.                                                     struct Gadget    *Incrementer;
  1113.  
  1114.                                                     if(Forward)
  1115.                                                     {
  1116.                                                         incNode = Node -> Special . Integer . RightIncrementer -> UserData;
  1117.  
  1118.                                                         Incrementer = Node -> Special . Integer . RightIncrementer;
  1119.                                                     }
  1120.                                                     else
  1121.                                                     {
  1122.                                                         incNode = Node -> Special . Integer . LeftIncrementer -> UserData;
  1123.  
  1124.                                                         Incrementer = Node -> Special . Integer . LeftIncrementer;
  1125.                                                     }
  1126.  
  1127.                                                     if(Parent -> Special . Integer . IncrementerHook)
  1128.                                                         Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),incNode -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  1129.                                                     else
  1130.                                                         Number = LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE) + incNode -> Special . Incrementer . Amount;
  1131.  
  1132.                                                     if(Number >= Parent -> Min && Number <= Parent -> Max)
  1133.                                                     {
  1134.                                                         LTP_BlinkButton(Handle,Incrementer);
  1135.  
  1136.                                                         LT_SetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
  1137.  
  1138.                                                         *MsgClass = IDCMP_GADGETUP;
  1139.  
  1140.                                                         LTP_PutStorage(Node);
  1141.                                                     }
  1142.                                                 }
  1143.                                                 else
  1144.                                                 {
  1145.                                                     ActivateGadget(Gadget,Handle -> Window,NULL);
  1146.  
  1147.                                                     *MsgClass = IDCMP_GADGETDOWN;
  1148.                                                 }
  1149.  
  1150.                                                 *MsgCode    = 0;
  1151.                                                 *MsgGadget    = Gadget;
  1152.  
  1153.                                                 Handle -> Previous = Gadget;
  1154.                                             }
  1155.                                             else
  1156.                                             {
  1157.                                                 if(Handle -> RawKeyFilter)
  1158.                                                     *MsgClass = NULL;
  1159.                                             }
  1160.  
  1161.                                             FoundIt = TRUE;
  1162.  
  1163.                                             break;
  1164.  
  1165.                                         case BUTTON_KIND:
  1166.  
  1167.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  1168.                                             {
  1169.                                                 LTP_BlinkButton(Handle,Gadget);
  1170.  
  1171.                                                 *MsgClass    = IDCMP_GADGETUP;
  1172.                                                 *MsgCode    = 0;
  1173.                                                 *MsgGadget    = Gadget;
  1174.                                             }
  1175.                                             else
  1176.                                             {
  1177.                                                 if(Handle -> RawKeyFilter)
  1178.                                                     *MsgClass = NULL;
  1179.                                             }
  1180.  
  1181.                                             FoundIt = TRUE;
  1182.  
  1183.                                             break;
  1184.                                     }
  1185.                                 }
  1186.                             }
  1187.                         }
  1188.                     }
  1189.                 }
  1190.  
  1191.                 if(FoundIt)
  1192.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  1193.             }
  1194.  
  1195.             break;
  1196.         }
  1197.  
  1198.         case IDCMP_GADGETDOWN:
  1199.  
  1200.             if(GETOBJECT((*MsgGadget),Node))
  1201.             {
  1202.                 if(Node -> Type != LISTVIEW_KIND)
  1203.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  1204.  
  1205.                 switch(Node -> Type)
  1206.                 {
  1207. #ifdef DO_LEVEL_KIND
  1208.                     case LEVEL_KIND:
  1209.  
  1210.                         Handle -> CurrentLevel = Node;
  1211.  
  1212.                         *MsgCode = Node -> Special . Level . Level;
  1213.  
  1214.                         break;
  1215. #endif    /* DO_LEVEL_KIND */
  1216.                     case STRING_KIND:
  1217.                     case INTEGER_KIND:
  1218.                     case FRACTION_KIND:
  1219.                     case PASSWORD_KIND:
  1220.  
  1221.                         Handle -> Previous = *MsgGadget;
  1222.                         break;
  1223. #ifdef DO_TAPEDECK_KIND
  1224.                     case TAPEDECK_KIND:
  1225.  
  1226.                         if(Node -> Special . TapeDeck . Tick)
  1227.                         {
  1228.                             Handle -> ActiveIncrementer    = Node;
  1229.                             Handle -> IncrementerCountdown    = 2;
  1230.  
  1231.                             *MsgClass    = IDCMP_GADGETUP;
  1232.                             *MsgCode    = 0;
  1233.                         }
  1234.                         else
  1235.                         {
  1236.                             if(Node -> Special . TapeDeck . Toggle)
  1237.                             {
  1238.                                 if((*MsgGadget) -> Flags & GFLG_SELECTED)
  1239.                                     *MsgCode = TRUE;
  1240.                                 else
  1241.                                     *MsgCode = FALSE;
  1242.  
  1243.                                 Node -> Current = *MsgCode;
  1244.  
  1245.                                 LTP_PutStorage(Node);
  1246.  
  1247.                                 if(Handle -> Previous && !Node -> PageSelector)
  1248.                                     Activate = TRUE;
  1249.  
  1250.                                 *MsgClass = IDCMP_GADGETUP;
  1251.                             }
  1252.                         }
  1253.  
  1254.                         break;
  1255. #endif    /* DO_TAPEDECK_KIND */
  1256.                     case MX_KIND:
  1257.  
  1258.                         if(!V39 && Node -> Disabled)
  1259.                         {
  1260.                             GT_SetGadgetAttrs(*MsgGadget,Handle -> Window,NULL,
  1261.                                 GTMX_Active,Node -> Current,
  1262.                             TAG_DONE);
  1263.  
  1264.                             *MsgClass = NULL;
  1265.                         }
  1266.                         else
  1267.                         {
  1268.                             Node -> Current = *MsgCode;
  1269.  
  1270.                             LTP_PutStorage(Node);
  1271.  
  1272.                             if(Node -> Special . Radio . AutoPageID != -1)
  1273.                             {
  1274.                                 LT_SetAttributes(Handle,Node -> Special . Radio . AutoPageID,
  1275.                                     LAGR_ActivePage,Node -> Current,
  1276.                                 TAG_DONE);
  1277.  
  1278.                                 if(Handle -> Failed)
  1279.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1280.                                 else
  1281.                                     *MsgClass = NULL;
  1282.                             }
  1283.  
  1284.                             if(Handle -> Previous && !Node -> PageSelector)
  1285.                                 Activate = TRUE;
  1286.                         }
  1287.  
  1288.                         break;
  1289.  
  1290.                     case SLIDER_KIND:
  1291.  
  1292.                         if(Node -> Min < 0)
  1293.                             Node -> Current = (WORD)*MsgCode;
  1294.                         else
  1295.                             Node -> Current = *MsgCode;
  1296.  
  1297.                         LTP_PutStorage(Node);
  1298.  
  1299.                         if(Handle -> Previous && !Node -> PageSelector)
  1300.                             Activate = TRUE;
  1301.  
  1302.                         break;
  1303.  
  1304.                     case SCROLLER_KIND:
  1305.  
  1306.                         Node -> Current = *MsgCode;
  1307.  
  1308.                         LTP_PutStorage(Node);
  1309.  
  1310.                         if(Handle -> Previous && !Node -> PageSelector)
  1311.                             Activate = TRUE;
  1312.  
  1313.                         break;
  1314.  
  1315.                     case INCREMENTER_KIND:
  1316.  
  1317.                         Handle -> ActiveIncrementer    = Node;
  1318.                         Handle -> IncrementerCountdown    = 6;
  1319.  
  1320.                         *MsgClass    = IDCMP_GADGETUP;
  1321.                         *MsgCode    = 0;
  1322.                         *MsgGadget    = Node -> Special . Incrementer . Parent;
  1323.  
  1324.                         /* ALWAYS */
  1325.                         {
  1326.                             struct ObjectNode    *Parent = (ObjectNode *)(*MsgGadget) -> UserData;
  1327.                             LONG             Number;
  1328.  
  1329.                             if(Parent -> Special . Integer . IncrementerHook)
  1330.                                 Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),Node -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  1331.                             else
  1332.                                 Number = LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE) + Node -> Special . Incrementer . Amount;
  1333.  
  1334.                             if(Number >= Parent -> Min && Number <= Parent -> Max)
  1335.                                 LT_SetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
  1336.                             else
  1337.                                 *MsgClass = NULL;
  1338.                         }
  1339.  
  1340.                         break;
  1341.                 }
  1342.             }
  1343.  
  1344.             break;
  1345.  
  1346.         case IDCMP_MOUSEBUTTONS:
  1347.  
  1348.             if(((*MsgCode) & IECODE_UP_PREFIX) && Handle -> Previous)
  1349.                 Activate = TRUE;
  1350.  
  1351.             if(*MsgCode == SELECTDOWN)
  1352.             {
  1353.                 ObjectNode    *Node;
  1354.                 WORD         x,y;
  1355.  
  1356.                 x = Handle -> Window -> MouseX;
  1357.                 y = Handle -> Window -> MouseY;
  1358.  
  1359.                 Node = LTP_FindNode_Position(Handle -> TopGroup,x,y);
  1360.  
  1361.                 if(Node && !Node -> Disabled)
  1362.                 {
  1363.                     WORD Index;
  1364.  
  1365.                     switch(Node -> Type)
  1366.                     {
  1367.                         case CHECKBOX_KIND:
  1368.  
  1369.                             Node -> Current = !Node -> Current;
  1370.  
  1371.                             LTP_PutStorage(Node);
  1372.  
  1373.                             GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
  1374.                                 GTCB_Checked,Node -> Current,
  1375.                             TAG_DONE);
  1376.  
  1377.                             *MsgClass    = IDCMP_GADGETUP;
  1378.                             *MsgCode    = Node -> Current;
  1379.                             *MsgGadget    = Node -> Host;
  1380.  
  1381.                             break;
  1382.  
  1383.                         case MX_KIND:
  1384.  
  1385.                             Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
  1386.  
  1387.                             if(Index != -1)
  1388.                             {
  1389.                                 GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
  1390.                                     GTMX_Active,Index,
  1391.                                 TAG_DONE);
  1392.  
  1393.                                 LTP_PutStorage(Node);
  1394.  
  1395.                                 *MsgClass    = IDCMP_GADGETDOWN;
  1396.                                 *MsgCode    = Index;
  1397.                                 *MsgGadget    = Node -> Host;
  1398.                             }
  1399.  
  1400.                             break;
  1401.                     }
  1402.                 }
  1403.             }
  1404.             else
  1405.             {
  1406.                     // Now this is a real kludge; as of v37 the
  1407.                     // MX_KIND labels are not part of the gadget
  1408.                     // itself and a plain SELECTDOWN mouse event
  1409.                     // is sent as soon as the user clicks on it.
  1410.                     // This changed with v39 which presumably had
  1411.                     // some code in there to map mouse clicks on
  1412.                     // the gadget labels to proper buttonpress
  1413.                     // events. Now, try as you might the click is
  1414.                     // swallowed and we have to do with the
  1415.                     // SELECTUP, sigh...
  1416.  
  1417.                 if(V39 && *MsgCode == SELECTUP)
  1418.                 {
  1419.                     ObjectNode    *Node;
  1420.                     WORD         x,y;
  1421.  
  1422.                     x = Handle -> Window -> MouseX;
  1423.                     y = Handle -> Window -> MouseY;
  1424.  
  1425.                     Node = LTP_FindNode_Position(Handle -> TopGroup,x,y);
  1426.  
  1427.                     if(Node && Node -> Type == MX_KIND && !Node -> Disabled)
  1428.                     {
  1429.                         WORD Index;
  1430.  
  1431.                         Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
  1432.  
  1433.                         if(Index != -1)
  1434.                         {
  1435.                             GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
  1436.                                 GTMX_Active,Index,
  1437.                             TAG_DONE);
  1438.  
  1439.                             LTP_PutStorage(Node);
  1440.  
  1441.                             *MsgClass    = IDCMP_GADGETDOWN;
  1442.                             *MsgCode    = Index;
  1443.                             *MsgGadget    = Node -> Host;
  1444.                         }
  1445.                     }
  1446.                 }
  1447.             }
  1448.  
  1449.             if((*MsgCode == SELECTUP) && (Handle -> ActiveIncrementer))
  1450.             {
  1451.                 if(Handle -> ActiveIncrementer -> Type == TAPEDECK_KIND && Handle -> ActiveIncrementer  -> Special . TapeDeck . Tick)
  1452.                 {
  1453.                     Handle -> ActiveIncrementer = NULL;
  1454.  
  1455.                     *MsgClass    = IDCMP_GADGETUP;
  1456.                     *MsgCode    = 1;
  1457.                 }
  1458.                 else
  1459.                 {
  1460.                     Handle -> ActiveIncrementer = NULL;
  1461.  
  1462.                     if(((ObjectNode *)Handle -> ActiveIncrementer -> Special . Incrementer . Parent -> UserData) -> Type == INTEGER_KIND)
  1463.                     {
  1464.                         *MsgGadget    = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
  1465.                         *MsgClass    = IDCMP_GADGETUP;
  1466.                         *MsgCode    = 1;
  1467.                     }
  1468.                 }
  1469.             }
  1470.  
  1471.             break;
  1472.  
  1473.         case IDCMP_GADGETUP:
  1474.  
  1475. #ifdef DO_LEVEL_KIND
  1476.             Handle -> CurrentLevel = NULL;
  1477. #endif    /* DO_LEVEL_KIND */
  1478.  
  1479.             if(GETOBJECT((*MsgGadget),Node))
  1480.             {
  1481.                 if(Node -> Type != LISTVIEW_KIND)
  1482.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  1483.  
  1484.                 switch(Node -> Type)
  1485.                 {
  1486.                     case FRACTION_KIND:
  1487.  
  1488.                         LT_SetAttributes(Handle,(*MsgGadget) -> GadgetID,LAFC_Number,LT_GetAttributes(Handle,(*MsgGadget) -> GadgetID,TAG_DONE),TAG_DONE);
  1489.  
  1490.                     /* FALLS THROUGH */
  1491.  
  1492.                     case PASSWORD_KIND:
  1493.                     case STRING_KIND:
  1494.  
  1495.                         LTP_PutStorage(Node);
  1496.  
  1497.                         if(*MsgCode == 0x5F && Handle -> HelpHook)
  1498.                         {
  1499.                             struct HelpMsg     Message;
  1500.                             struct IBox     Box;
  1501.  
  1502.                             Message . ObjectID = Node -> ID;
  1503.  
  1504.                             Box . Left    = Node -> Left;
  1505.                             Box . Top    = Node -> Top;
  1506.                             Box . Width    = Node -> Width;
  1507.                             Box . Height    = Node -> Height;
  1508.  
  1509.                             Message . Handle = Handle;
  1510.  
  1511.                             CallHookPkt(Handle -> HelpHook,&Message,&Box);
  1512.  
  1513.                             *MsgClass = NULL;
  1514.                         }
  1515.                         else
  1516.                             Handle -> Previous = NULL;
  1517.  
  1518.                         break;
  1519.  
  1520.                     case INTEGER_KIND:
  1521.                     {
  1522.                         struct StringInfo *StringInfo = (struct StringInfo *)(*MsgGadget) -> SpecialInfo;
  1523.                         LONG Contents = StringInfo -> LongInt;
  1524.  
  1525.                         if(Contents < Node -> Min)
  1526.                             Contents = Node -> Min;
  1527.                         else
  1528.                         {
  1529.                             if(Contents > Node -> Max)
  1530.                                 Contents = Node -> Max;
  1531.                         }
  1532.  
  1533.                         LT_SetAttributes(Handle,(*MsgGadget) -> GadgetID,GTIN_Number,Contents,TAG_DONE);
  1534.  
  1535.                         LTP_PutStorage(Node);
  1536.  
  1537.                         if(*MsgCode == 0x5F && Handle -> HelpHook)
  1538.                         {
  1539.                             struct HelpMsg     Message;
  1540.                             struct IBox     Box;
  1541.  
  1542.                             Message . ObjectID = Node -> ID;
  1543.  
  1544.                             Box . Left    = Node -> Left;
  1545.                             Box . Top    = Node -> Top;
  1546.                             Box . Width    = Node -> Width;
  1547.                             Box . Height    = Node -> Height;
  1548.  
  1549.                             Message . Handle = Handle;
  1550.  
  1551.                             CallHookPkt(Handle -> HelpHook,&Message,&Box);
  1552.  
  1553.                             *MsgClass = NULL;
  1554.                         }
  1555.                         else
  1556.                             Handle -> Previous = NULL;
  1557.  
  1558.                         break;
  1559.                     }
  1560.  
  1561.                     case CHECKBOX_KIND:
  1562.  
  1563.                         if(!V39)
  1564.                         {
  1565.                             if((*MsgGadget) -> Flags & GFLG_SELECTED)
  1566.                                 *MsgCode = TRUE;
  1567.                             else
  1568.                                 *MsgCode = FALSE;
  1569.                         }
  1570.  
  1571.                         Node -> Current = *MsgCode;
  1572.  
  1573.                         LTP_PutStorage(Node);
  1574.  
  1575.                         if(Handle -> Previous && !Node -> PageSelector)
  1576.                             Activate = TRUE;
  1577.  
  1578.                         break;
  1579. #ifdef DO_TAPEDECK_KIND
  1580.                     case TAPEDECK_KIND:
  1581.  
  1582.                         if(Node -> Special . TapeDeck . Tick)
  1583.                         {
  1584.                             Handle -> ActiveIncrementer = NULL;
  1585.  
  1586.                             *MsgClass    = IDCMP_GADGETUP;
  1587.                             *MsgCode    = 1;
  1588.                         }
  1589.                         else
  1590.                         {
  1591.                             if(Node -> Special . TapeDeck . Toggle)
  1592.                             {
  1593.                                 if((*MsgGadget) -> Flags & GFLG_SELECTED)
  1594.                                     *MsgCode = TRUE;
  1595.                                 else
  1596.                                     *MsgCode = FALSE;
  1597.  
  1598.                                 Node -> Current = *MsgCode;
  1599.  
  1600.                                 LTP_PutStorage(Node);
  1601.                             }
  1602.                         }
  1603.  
  1604.                         if(Handle -> Previous && !Node -> PageSelector)
  1605.                             Activate = TRUE;
  1606.  
  1607.                         break;
  1608. #endif    /* DO_TAPEDECK_KIND */
  1609.                     case CYCLE_KIND:
  1610.  
  1611.                         Node -> Current = *MsgCode;
  1612.  
  1613.                         LTP_PutStorage(Node);
  1614.  
  1615.                         if(Handle -> Previous && !Node -> PageSelector)
  1616.                             Activate = TRUE;
  1617.  
  1618.                         if(Node -> Special . Cycle . AutoPageID != -1)
  1619.                         {
  1620.                             LT_SetAttributes(Handle,Node -> Special . Cycle . AutoPageID,
  1621.                                 LAGR_ActivePage,Node -> Current,
  1622.                             TAG_DONE);
  1623.  
  1624.                             if(Handle -> Failed)
  1625.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1626.                             else
  1627.                                 *MsgClass = NULL;
  1628.                         }
  1629.  
  1630.                         break;
  1631.  
  1632.                     case PALETTE_KIND:
  1633.  
  1634.                         Node -> Current = *MsgCode;
  1635.  
  1636.                         LTP_PutStorage(Node);
  1637.  
  1638.                         if(Handle -> Previous && !Node -> PageSelector)
  1639.                             Activate = TRUE;
  1640.  
  1641.                         break;
  1642.  
  1643.                     case MX_KIND:
  1644.  
  1645.                         if(!V39 && Node -> Disabled)
  1646.                         {
  1647.                             GT_SetGadgetAttrs(*MsgGadget,Handle -> Window,NULL,
  1648.                                 GTMX_Active,Node -> Current,
  1649.                             TAG_DONE);
  1650.  
  1651.                             *MsgClass = NULL;
  1652.                         }
  1653.                         else
  1654.                         {
  1655.                             Node -> Current = *MsgCode;
  1656.  
  1657.                             LTP_PutStorage(Node);
  1658.  
  1659.                             if(Node -> Special . Radio . AutoPageID != -1)
  1660.                             {
  1661.                                 LT_SetAttributes(Handle,Node -> Special . Radio . AutoPageID,
  1662.                                     LAGR_ActivePage,Node -> Current,
  1663.                                 TAG_DONE);
  1664.  
  1665.                                 if(Handle -> Failed)
  1666.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1667.                                 else
  1668.                                     *MsgClass = NULL;
  1669.                             }
  1670.  
  1671.                             if(Handle -> Previous && !Node -> PageSelector)
  1672.                                 Activate = TRUE;
  1673.                         }
  1674.  
  1675.                         break;
  1676.  
  1677.                     case SLIDER_KIND:
  1678.  
  1679.                         if(Node -> Min < 0)
  1680.                             Node -> Current = (WORD)*MsgCode;
  1681.                         else
  1682.                             Node -> Current = *MsgCode;
  1683.  
  1684.                         LTP_PutStorage(Node);
  1685.  
  1686.                         if(Handle -> Previous && !Node -> PageSelector)
  1687.                             Activate = TRUE;
  1688.  
  1689.                         break;
  1690. #ifdef DO_LEVEL_KIND
  1691.                     case LEVEL_KIND:
  1692.  
  1693. //                        *MsgClass    = IDCMP_MOUSEMOVE;    // Careful, may cause trouble with existing applications!
  1694.                         *MsgCode    = Node -> Special . Level . Level;
  1695.                         *MsgGadget    = Node -> Host;
  1696.  
  1697.                         LTP_PutStorage(Node);
  1698.  
  1699.                         break;
  1700. #endif    /* DO_LEVEL_KIND */
  1701.                     case SCROLLER_KIND:
  1702.  
  1703.                         Node -> Current = *MsgCode;
  1704.  
  1705.                         LTP_PutStorage(Node);
  1706.  
  1707.                         if(Handle -> Previous && !Node -> PageSelector)
  1708.                             Activate = TRUE;
  1709.  
  1710.                         break;
  1711.  
  1712.                     case PICKER_KIND:
  1713.  
  1714.                         *MsgClass    = IDCMP_IDCMPUPDATE;
  1715.                         *MsgCode    = 0;
  1716.                         *MsgGadget    = Node -> Special . Picker . Parent;
  1717.  
  1718.                         if(Handle -> Previous && !Node -> PageSelector)
  1719.                             Activate = TRUE;
  1720.  
  1721.                         break;
  1722.  
  1723.                     case INCREMENTER_KIND:
  1724.  
  1725.                         if(((ObjectNode *)Handle -> ActiveIncrementer -> Special . Incrementer . Parent -> UserData) -> Type == INTEGER_KIND)
  1726.                         {
  1727.                             *MsgGadget    = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
  1728.                             *MsgClass    = IDCMP_GADGETUP;
  1729.                             *MsgCode    = 1;
  1730.                         }
  1731.  
  1732.                         Handle -> ActiveIncrementer = NULL;
  1733.                         break;
  1734.  
  1735.                     case LISTVIEW_KIND:
  1736.  
  1737.                         if(Node -> Current != *MsgCode || Node != Handle -> ClickObject)
  1738.                         {
  1739.                             CurrentTime(&Handle -> ClickSeconds,&Handle -> ClickMicros);
  1740.  
  1741.                             Handle -> ClickObject = Node;
  1742.                         }
  1743.                         else
  1744.                         {
  1745.                             ULONG Seconds,Micros;
  1746.  
  1747.                             CurrentTime(&Seconds,&Micros);
  1748.  
  1749.                             if(DoubleClick(Handle -> ClickSeconds,Handle -> ClickMicros,Seconds,Micros))
  1750.                                 *MsgClass = IDCMP_IDCMPUPDATE;
  1751.  
  1752.                             Handle -> ClickSeconds    = Seconds;
  1753.                             Handle -> ClickMicros    = Micros;
  1754.                         }
  1755.  
  1756.                         Node -> Current = *MsgCode;
  1757.  
  1758.                         LTP_PutStorage(Node);
  1759.  
  1760.                         if(Node -> Special . List . Link)
  1761.                         {
  1762.                             Handle -> Previous = Node -> Special . List . Link;
  1763.  
  1764.                             if(!Node -> PageSelector)
  1765.                                 Activate = TRUE;
  1766.                         }
  1767.                         else
  1768.                         {
  1769.                             if(Handle -> Previous && !Node -> PageSelector)
  1770.                                 Activate = TRUE;
  1771.                         }
  1772.  
  1773.                         break;
  1774.  
  1775.                     default:
  1776.  
  1777.                         if(Handle -> Previous && !Node -> PageSelector)
  1778.                             Activate = TRUE;
  1779.  
  1780.                         break;
  1781.                 }
  1782.             }
  1783.  
  1784.             break;
  1785.  
  1786.         case IDCMP_MOUSEMOVE:
  1787.  
  1788. #ifdef DO_LEVEL_KIND
  1789.             if(Handle -> CurrentLevel)
  1790.                 Node = Handle -> CurrentLevel;
  1791.             else
  1792. #endif
  1793.                 GETOBJECT((*MsgGadget),Node);
  1794.  
  1795.             if(Node)
  1796.             {
  1797.                 if(Node -> Type != LISTVIEW_KIND)
  1798.                     Handle -> ClickSeconds = Handle -> ClickMicros = 0;
  1799.  
  1800.                 switch(Node -> Type)
  1801.                 {
  1802.                     case SLIDER_KIND:
  1803.  
  1804.                         if(Node -> Min < 0)
  1805.                             Node -> Current = (WORD)*MsgCode;
  1806.                         else
  1807.                             Node -> Current = *MsgCode;
  1808.  
  1809.                         LTP_PutStorage(Node);
  1810.  
  1811.                         break;
  1812.  
  1813.                     case SCROLLER_KIND:
  1814.  
  1815.                         Node -> Current = *MsgCode;
  1816.  
  1817.                         LTP_PutStorage(Node);
  1818.  
  1819.                         break;
  1820.  
  1821. #ifdef DO_LEVEL_KIND
  1822.                     case LEVEL_KIND:
  1823.  
  1824.                         *MsgCode    = Node -> Special . Level . Level;
  1825.                         *MsgGadget      = Node -> Host;
  1826.  
  1827.                         LTP_PutStorage(Node);
  1828.  
  1829.                         break;
  1830. #endif    /* DO_LEVEL_KIND */
  1831.                 }
  1832.             }
  1833.  
  1834.             break;
  1835.  
  1836.         case IDCMP_ACTIVEWINDOW:
  1837.  
  1838.             if(Handle -> Previous)
  1839.             {
  1840.                 Activate = TRUE;
  1841.  
  1842.                 *MsgClass    = IDCMP_GADGETDOWN;
  1843.                 *MsgCode    = 0;
  1844.                 *MsgGadget    = Handle -> Previous;
  1845.             }
  1846.  
  1847.             break;
  1848.  
  1849.         case IDCMP_INACTIVEWINDOW:
  1850.  
  1851.             Handle -> ActiveIncrementer = NULL;
  1852.             break;
  1853.     }
  1854.  
  1855.     if(Handle -> AutoActivate && Activate && Handle -> Previous)
  1856.     {
  1857.         if(GETOBJECT(Handle -> Previous,Node))
  1858.         {
  1859.             if(!Node -> Disabled)
  1860.             {
  1861.                 if(Node -> Type == BOOPSI_KIND && Node -> Special . BOOPSI . ActivateHook)
  1862.                     CallHookPkt(Node -> Special . BOOPSI . ActivateHook,(APTR)Handle,(APTR)Node -> Host);
  1863.                 else
  1864.                     ActivateGadget(Handle -> Previous,Handle -> Window,NULL);
  1865.             }
  1866.         }
  1867.     }
  1868. }
  1869.